<template>
  <a-modal
    title="新增类目"
    width="45%"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    destroyOnClose
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item
          label="服务类型"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-input
            v-decorator="['serviceType', {
              rules: [{required: true, message: '请输入服务类型'}]}]" />
        </a-form-item>
        <a-form-item
          label="开票类目"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-input
            v-decorator="['invoiceCategory', {
              rules: [{required: true, message: '请输入开票类目'}]}]" />
        </a-form-item>
        <a-form-item
          label="具体服务内容"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-textarea
            v-decorator="['content', {
              rules: [{required: true, message: '请输入具体服务内容'}]}]" />
        </a-form-item>

      </a-form>
    </a-spin>
  </a-modal>
</template>
<script>
import { addInvoiceType } from '@/api/manage'
export default {
  name: 'AddMail',

  data() {
    return {
      //   mailAddrs: {
      //   },
      type:{},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 13 }
      },
      form: this.$form.createForm(this),
      visible: false,
      confirmLoading: false,
      timer: null,
      time: 90,
      isNewPhoneModal: true
    }
  },
  created() {

  },
  methods: {
    show() {
      //   console.log(record)
      //   this.mailAddrs = record
      this.visible = true
    },


    handleCancel() {
      this.visible = false
    },
    handleSubmit() {
         this.form.validateFields((err, value) => {
        if(!err){
            const Type = {
          serviceType: value.serviceType,
          content: value.content,
          invoiceCategory: value.invoiceCategory,
        }
        this.type=Type
        addInvoiceType(this.type)
        .then(res => {
          console.log(res)
          this.handleCancel()
          this.$emit('onSuccess')
        })
        }
      })

      // this.confirmLoading = true
      // this.form.validateFields((errors, values) => {
      //   if (!errors) {
      //     loginPasswordPhone({ newPassword: values.newPassword, phone: values.phone, smsVerifyCode: values.smsVerifyCode })
      //       .then(() => {
      //         this.GetInfo()
      //         this.handleCancel()
      //         this.$message.success('修改密码成功')
      //       })
      //       .finally(() => { this.confirmLoading = false })
      //   } else {
      //     this.confirmLoading = false
      //   }
      // })
    }
  }
}
</script>

<style scoped>
</style>
